<!-- 业务员列表 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">业务员列表</p>
    <dxtable :dataJson="dataJson" :portUrl="portUrl" :formJson="formJson" :qx="qx" imgkuTitle="业务员头像" :isBfy="true"
      @getlistId="getlistId"></dxtable>
    <!-- :czFun="czFun" -->
  </div>
</template>
<script lang='ts' setup>
import { leixing } from "../../util/config";
import dxtable from "../../components/util/dxtable.vue";
import { dxget } from "../../util/index";
import { NButton } from "naive-ui"
import { h, ref, reactive } from "vue";
let qxList = ref([]);
const jjhser = ref()
let dataJson = [
  {
    title: "头像",
    key: "headPortrait",
    type: "img", //类型
  },
  {
    title: "账号",
    key: "userNmae",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "姓名",
    key: "userNickname",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "手机号",
    key: "phone",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "最近一次拿货时间",
    sorter: 'default',
    sorter(rowA, rowB) {
      try {
        return jjhser.value[rowA.id].DateDelivery - jjhser.value[rowB.id].DateDelivery
      } catch (e) {
        return '--'
      }
    },
    render(row) {
      try {
        return jjhser.value[row.id].DateDelivery || '--'
      } catch (e) {
        return '--'
      }
    }
  },

  {
    title: "最近一次拿货数量",
    sorter: 'default',
    sorter(rowA, rowB) {
      try {
        return jjhser.value[rowA.id].QuantityGoodsReceived - jjhser.value[rowB.id].QuantityGoodsReceived
      } catch (e) {
        return '--'
      }
    },
    render(row) {
      try {
        return jjhser.value[row.id].QuantityGoodsReceived || '--'
      } catch (e) {
        return '--'
      }
    }
  },
  {
    title: "拿货总数",
    sorter: 'default',
    sorter(rowA, rowB) {
      try {
        return jjhser.value[rowA.id].nhzs - jjhser.value[rowB.id].nhzs
      } catch (e) {
        return '--'
      }
    },
    render(row) {
      try {
        return jjhser.value[row.id].nhzs || '--'
      } catch (e) {
        return '--'
      }
    }
  }, 

  
  {
    title: "客户总数",
    sorter: 'default',
    sorter(rowA, rowB) {
      try {
        return jjhser.value[rowA.id].zs - jjhser.value[rowB.id].zs
      } catch (e) {
        return '--'
      }
    },
    render(row) {
      try {
        return jjhser.value[row.id].zs || '--'
      } catch (e) {
        return '--'
      }
    }
  },
 
  {
    title: "创建时间",
    key: "addTime",
  },
];
const qx = {
  DeletePermissionID: "sasalesmandel", //删除
  EditPermissionIdentifier: "sasalesmanbj", // 编辑
  NewPermissionIdentifier: "sasalesmanxz", // 新建
  ViewPermissionID: "sasalesmanck", // 查看
};
// const portUrl = "dxgjAdmin/administrator?CharacterNameCode=" + leixing;
const portUrl = "dxgjAdmin/administrator?CharacterNameCode=42&pageSize=999";
let formJson = reactive([
  {
    title: "账号",
    type: "input",
    key: "userNmae",
    required: true, // 是否为必填
  },
  {
    title: "密码",
    type: "password",
    key: "userPassword",
    required: true, // 是否为必填
  },
  {
    title: "姓名",
    key: "userNickname",
    type: "input",
    required: true, // 是否为必填
  },
  {
    title: "手机号",
    key: "phone",
    type: "input",
    required: true, // 是否为必填
  },
  {
    key: "CharacterNameCode",
    val: 42
  },
  {
    title: "头像",
    key: "headPortrait",
    type: "img", //类型
    required: true, // 是否为必填
  },
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {
            alert("此功能正在开发")
          },
        },
        "关联账号"
      ),
    ];
  },
};
const getlistId = async (data) => {

  const res: any = await dxget("salesManagement/api/getebtor", {
    id: data
  })
  jjhser.value = res.data

}
</script>
<style scoped></style>